package com.dgut;


import io.jsonwebtoken.Claims;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

import java.util.Date;


@SpringBootApplication(scanBasePackages = "com.dgut")
@MapperScan("com.dgut.dao")
public class WebApplication {
    public static void main(String[] args) {
        SpringApplication.run(WebApplication.class, args);
//        String token = Jwts.builder()
//                .setSubject("niceyoo")
//                .claim("authorities","admin")
//                .setExpiration(new Date(System.currentTimeMillis() + 7 * 60 * 1000))
//                .signWith(SignatureAlgorithm.HS512, "tmax")
//                .compact();
//        System.out.println(token);

//        try {
//            Claims claims = Jwts.parser()
//                    .setSigningKey("tmax")
//                    .parseClaimsJws("eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJuaWNleW9vIiwiYXV0aG9yaXRpZXMiOiJhZG1pbiIsImV4cCI6MTU2OTM3NTczNX0.401Z2BCqmNwOb5ADn-_Gu9sDyooS0eyywNr1CagHE_C8zR9TCqqj1mdkGhax4DVwKjRlkXkOP9wPYD4kX4gPYA")
//                    .getBody();
//
//            System.out.println(claims);
//            String username = claims.getSubject();
//            System.out.println("username:"+username);
//            String authority = claims.get("authorities").toString();
//            System.out.println("权限："+authority);
//        } catch (ExpiredJwtException e) {
//            System.out.println("jwt异常");
//        } catch (Exception e){
//            System.out.println("异常");
//        }


    }



}
